package com.ming.util;

import com.github.pagehelper.PageInfo;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.util.List;

/**
 * 分页工具类
 * Created by lx on 2017/7/14.
 */
@Getter
@Setter
@ToString
public class Pager {


    private Integer code = 0;
    private String msg = "";
    private long count; //总条数

    private List data;          //数据

    /**
     * 将 PageInfo 转换成我们需要的 Pager
     * @param pageInfo
     * @return
     */
    public static Pager toPage(PageInfo pageInfo){
        if (pageInfo != null){
            Pager pager = new Pager();
            pager.setCount(pageInfo.getTotal());
            pager.setData(pageInfo.getList());
            return pager;
        }
        return null;
    }

}
